﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.models {
    import net.wooga.pets.events.*;
    import mx.utils.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;
    import net.wooga.pets.utils.*;
	import com.adobe.utils.*;

    public class LanguageModel extends Actor {

        private var _original:Object;
        private var _locale:String;
        private var _ids:Object;

        public function LanguageModel(){
            this._original = {};
            this._ids = {};
        }
        public function get languageCollection():Object{
            return (this._ids);
        }
        public function set languageCollection(_arg1:Object):void{
            this._original = _arg1;
            this.resetData();
        }
        public function getTextByKey(_arg1:String, _arg2:Object=null, _arg3:Boolean=true):String{
            var _local5:String;
            var _local6:String;
            var _local4:String = this.getText(_arg1, _arg3);
            for (_local6 in _arg2) {
                if (((_local4) && (!((_arg2[_local6] == null))))){
                    _local5 = this.getTextByKey(_arg2[_local6], null, false);
                    _local4 = Strings.replacePattern(_local4, _local6, _local5);
                };
            };
            return (((_local4) || (_arg1)));
        }
        private function getText(_arg1:String, _arg2:Boolean):String{
            var _local4:String;
            _arg1 = com.adobe.utils.StringUtil.trim(_arg1);
            var _local3:String = this._ids[_arg1];
            if (((!(_local3)) && (_arg2))){
                _local4 = ((("Missing value in language data for " + _arg1) + " in ") + this._locale);
                dispatch(new InfoEvent(EventConstants.REPORT_PROBLEM, _local4));
                l(("e " + _local4));
            };
            if (_local3){
                _local3 = ((this.getText(_local3, false)) || (_local3));
            };
            return (_local3);
        }
        public function replaceUsernamePlacehholders(_arg1:String):void{
            var _local2:String;
            var _local3:String;
            this.resetData();
            for (_local3 in this._ids) {
                if (this._ids[_local3].search("username") != -1){
                    _local2 = this.getTextByKey(_local3, {username:_arg1});
                    this._ids[_local3] = _local2;
                };
            };
        }
        public function replaceFormatTags():void{
            var _local1:String;
            for (_local1 in this._ids) {
                this._ids[_local1] = RepriseUtils.convertAllTagsToCSSClasses(this._ids[_local1]);
            };
        }
        public function parseTreatmentTime(_arg1:int):String{
            var _local7:String;
            var _local8:String;
            var _local2 = 60;
            var _local3 = 3600;
            var _local4:int = (_arg1 % 60);
            var _local5:int = int((_arg1 / _local2));
            var _local6:Number = Numbers.decimalPlaces((_local5 / _local2), 1);
            if (_arg1 < _local2){
                _local7 = _local4.toString();
                _local8 = "global_seconds";
            } else {
                if (_arg1 < _local3){
                    _local7 = _local5.toString();
                    _local8 = "global_minutes";
                } else {
                    _local7 = _local6.toString();
                    _local8 = "global_hours";
                };
            };
            return (((_local7.toString() + " ") + this.getTextByKey(_local8)));
        }
        public function get locale():String{
            return (this._locale);
        }
        public function set locale(_arg1:String):void{
            this._locale = _arg1;
        }
        private function resetData():void{
            this._ids = ObjectUtil.copy(this._original);
        }

    }
}//package net.wooga.pets.models 
